﻿<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="E-Mail_ID_Request_Form.aspx.cs"
    Inherits="Trig_AMJ_IT_Customforms.Layouts.Trig_AMJ_IT_Forms.E_Mail_ID_Request_Form"
    DynamicMasterPageFile="~masterurl/default.master" %>

<%@ Register TagPrefix="trig" TagName="userInfo" Src="~/_controltemplates/Trig_AMJ_IT_Forms/UserProfileInfo.ascx" %>
<%@ Register TagPrefix="trig" TagName="EmailComments" Src="~/_controltemplates/Trig_AMJ_AMG_Forms/TrigAMJFormsComments/TrigAMJFormsCommentsUserControl.ascx" %>
<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <link rel="Stylesheet" type="text/css" href="/_layouts/1033/STYLES/Themable/FORMS.CSS" />
    <link rel="Stylesheet" type="text/css" href="/Style Library/Al Majed/CSS/Trig_IT.css" />
    <script src="/_layouts/Scripts/validations.js" type="text/javascript" language="javascript"></script>
    <style type="text/css">
        #s4-leftpanel
        {
            display: none;
        }
        .s4-ca
        {
            margin-left: 0px;
        }
        .ms-formvalidation
        {
            color: Red;
        }
        .ms-validations
        {
            color: Red;
        }
        .tds
        {
            width: 20%;
        }
    </style>
</asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <asp:Panel ID="pnlFullForm" runat="server" CssClass="pnlAMFform">
        <table cellpadding="0" cellspacing="0" width="800" class="tbl-main">
            <tr>
                <td colspan="4" class="formtitle">
                    E-mail ID Request Form
                </td>
            </tr>
            <tr>
                <td width="158" colspan="1">
                    Reference Number :
                </td>
                <td colspan="2">
                    <asp:Label ID="lblEmailReqNo" runat="server" Text="Reference number will be generated upon save"
                        Font-Bold="True" Font-Size="XX-Small" ForeColor="Red" CssClass="ms-long ms-spellcheck-true"></asp:Label>
                </td>
                <td width="177" colspan="1" rowspan="2" align="right" class="UserInfo-Sec-td">
                    <trig:userInfo runat="server" ID="userInfo" Visible="true" />
                </td>
            </tr>
            <tr>
                <td colspan="1">
                    Request Date :
                </td>
                <td colspan="2">
                    <SharePoint:DateTimeControl ID="dtpDate" runat="server" DateOnly="true" Enabled="false"
                        LocaleId="2057" />
                </td>
            </tr>
            <tr>
                <td colspan="4" class="tdHeadingTextLeftAlign">
                    New E-mail ID for
                </td>
            </tr>
            <tr>
                <td>
                    First Name <span title="This is a required field." class="ms-validations"><strong>*</strong></span>
                </td>
                <td width="181" class="tdCell">
                    <asp:TextBox runat="server" ID="txtFirstName" Width="250px"></asp:TextBox>
                </td>
                <td width="191">
                    Last Name <span title="This is a required field." class="ms-validations"><strong>*</strong></span>
                </td>
                <td>
                    <asp:TextBox runat="server" ID="txtLastName" Width="250px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Division <span title="This is a required field." class="ms-validations"><strong>*</strong></span>
                </td>
                <td>
                    <asp:DropDownList runat="server" ID="ddlDivision" AutoPostBack="true" Width="250px"
                        OnSelectedIndexChanged="ddlDivision_SelectedIndexChanged">
                    </asp:DropDownList>
                </td>
                <td>
                    Department
                </td>
                <td>
                    <asp:DropDownList runat="server" ID="ddlDepartment" AutoPostBack="true" Width="250px">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    Mobile No
                </td>
                <td>
                    <asp:TextBox runat="server" ID="txtMailUserMobNo" Width="250px" onkeypress="return isNumberKey(this)"></asp:TextBox>
                </td>
                <td>
                    User Name Suggestion <span title="This is a required field." class="ms-validations">
                        <strong>*</strong></span>
                </td>
                <td>
                    <asp:TextBox runat="server" ID="txtUserNameSuggestion" Width="250px"></asp:TextBox>
                </td>
            </tr>
            <asp:Panel runat="server" ID="pnlMailCreateInfo" Visible="false">
                <tr>
                    <td colspan="4" class="tdHeadingTextLeftAlign">
                        For IT Manager
                    </td>
                </tr>
                <tr>
                    <td>
                        User Name <span title="This is a required field." class="ms-validations"><strong>*</strong></span>
                    </td>
                    <td class="tdCell">
                        <asp:TextBox runat="server" ID="txtUserName" Width="250px"></asp:TextBox>
                    </td>
                    <td>
                        e-mail Address <span title="This is a required field." class="ms-validations"><strong>
                            *</strong></span>
                    </td>
                    <td>
                        <asp:TextBox runat="server" ID="txtemailAdd" Width="250px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td colspan="1">
                        Password <span title="This is a required field." class="ms-validations"><strong>*</strong></span>
                    </td>
                    <td colspan="3">
                        <asp:TextBox ID="txtPassWord" runat="server" TextMode="Password" Width="250px" />
                        <asp:TextBox ID="txtPassView" runat="server" TextMode="SingleLine" Enabled="false"
                            Width="250px" />
                        <asp:TextBox ID="txtViewPass" runat="server" Visible="false" Width="250px" />
                    </td>
                </tr>
                <tr>
                    <td colspan="1">
                    </td>
                    <td colspan="3">
                        <asp:CheckBox ID="ckPassWord" runat="server" AutoPostBack="True" Text=" Show the characters"
                            onclick="javascript:return fnViewPass();" />
                    </td>
                </tr>
            </asp:Panel>
            <tr>
                <td colspan="4" class="tdHeadingTextLeftAlign">
                    Comments / Workflow Area
                </td>
            </tr>
            <tr>
                <td colspan="4" style="padding: 10px;">
                    <trig:EmailComments ID="emailComments" runat="server" />
                </td>
            </tr>
            <tr>
                <td colspan="4" style="padding: 5px">
                    <table width="100%" cellpadding="0" cellspacing="0" class="Section-Approver">
                        <asp:Panel ID="pnlCommentArea" runat="server" class="Section-Approver">
                            <tr>
                                <td colspan="4" class="AppHeading">
                                    <strong>Comments</strong><span class="ms-validations" title="This is a required field."><strong>
                                        *</strong></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="tdCell" width="210px">
                                    <asp:Image ID="ImgUser" runat="server" Height="50px" Width="50px" />
                                    <br />
                                    <asp:Label ID="LblCommentsUserName" runat="server" Font-Bold="True" Font-Size="XX-Small"
                                        ForeColor="#003399" Text=""></asp:Label>
                                </td>
                                <td colspan="3" class="tdCell">
                                    <asp:TextBox ID="TxtComments" runat="server" TextMode="MultiLine" Width="600px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr id="upAtt" runat="server">
                                <td class="tdCell" width="210px">
                                    Upload Attachment
                                </td>
                                <td colspan="3" class="tdCell">
                                    <asp:FileUpload ID="upfile" runat="server" CssClass="ms-fileinput" Width="250px" />
                                </td>
                            </tr>
                        </asp:Panel>
                        <asp:Panel ID="pnlForward" runat="server" Visible="false">
                            <tr>
                                <td colspan="4" style="text-align: left; background-color: #121e66; color: #ffffff;
                                    font-weight: bold; padding: 10px;">
                                    <table cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td>
                                                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                                    <ContentTemplate>
                                                        <asp:RadioButton ID="rtbSendBack" runat="server" Text="Send Back" GroupName="Users"
                                                            AutoPostBack="true" onclick="javascript:fnSendBackUsers(this)" />
                                                    </ContentTemplate>
                                                    <Triggers>
                                                        <asp:AsyncPostBackTrigger ControlID="rtbSendBack" EventName="CheckedChanged" />
                                                    </Triggers>
                                                </asp:UpdatePanel>
                                            </td>
                                            <td>
                                                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                                    <ContentTemplate>
                                                        <asp:RadioButton ID="rtbForwardOthers" runat="server" Text="Forward to other user"
                                                            AutoPostBack="true" GroupName="Users" onclick="javascript:fnForwardUsers(this)" />
                                                    </ContentTemplate>
                                                    <Triggers>
                                                        <asp:AsyncPostBackTrigger ControlID="rtbForwardOthers" EventName="CheckedChanged" />
                                                    </Triggers>
                                                </asp:UpdatePanel>
                                            </td>
                                            <td>
                                                <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                                                    <ContentTemplate>
                                                        <asp:RadioButton ID="rtbForward" runat="server" Text="Forward" GroupName="Users"
                                                            AutoPostBack="true" onclick="javascript:fnForword(this)" />
                                                    </ContentTemplate>
                                                    <Triggers>
                                                        <asp:AsyncPostBackTrigger ControlID="rtbForward" EventName="CheckedChanged" />
                                                    </Triggers>
                                                </asp:UpdatePanel>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="3">
                                                <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                                                    <ContentTemplate>
                                                        <asp:Label ID="lblWFStaticUser" runat="server" Text="" Font-Bold="True" Font-Size="XX-Small"
                                                            ForeColor="Yellow"></asp:Label>
                                                        <asp:Label ID="lblSendBacktoUser" runat="server" Text="" Font-Bold="True" Font-Size="XX-Small"
                                                            ForeColor="Yellow" Visible="false"></asp:Label>
                                                        <asp:Label ID="lblsendBackUserValue" runat="server" Text="" Font-Bold="True" Font-Size="XX-Small"
                                                            ForeColor="Yellow"></asp:Label></ContentTemplate>
                                                </asp:UpdatePanel>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr style="padding: 10px; display: none" id="trotherUsers">
                                <td style="padding: 10px; font-weight: bold; color: #121e66;" width="130px">
                                    User Name :
                                </td>
                                <td style="padding: 10px;" colspan="3">
                                    <asp:Label ID="lblCNTSectionMsg" runat="server" Text=""></asp:Label>
                                    <SharePoint:PeopleEditor ID="pplcnt" runat="server" MultiSelect="false" AllowEmpty="false"
                                        Width="250px" ForeColor="Red" AutoPostBack="false" />
                                </td>
                            </tr>
                        </asp:Panel>
                        <asp:Panel runat="server" ID="btnCntrls">
                            <tr>
                                <td colspan="4">
                                    <asp:UpdatePanel ID="UpdatePanel5" runat="server">
                                        <ContentTemplate>
                                            <asp:Label ID="lblError" runat="server" CssClass="error-msg" Text=""></asp:Label>
                                        </ContentTemplate>
                                    </asp:UpdatePanel>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="4" class="tblButtons" style="padding-top: 5px;">
                                    <asp:Button ID="btnSubmit" runat="server" CssClass="btn-Submit" Text="Submit" OnClientClick="javascript:return fnValidation();" />
                                    <asp:Button ID="btnApprove" runat="server" CssClass="btn-Approver" Text="Approve"
                                        OnClientClick="javascript:return fnValidation();" Visible="false" />
                                    <asp:Button ID="btnReject" runat="server" CssClass="btn-Reject" Text="Reject" Visible="false"
                                        OnClientClick="javascript:return fnValidation();" />
                                    <input id="btnCancel" class="btn-Cancel" type="button" value="Close" accesskey="C"
                                        onclick="window.parent.history.back()" runat="server" />
                                </td>
                            </tr>
                        </asp:Panel>
                    </table>
                </td>
            </tr>
            <asp:Panel ID="pnlView" runat="server" Visible="false">
                <tr>
                    <td style="text-align: center; padding-top: 10px" colspan="4">
                        <input id="btnViewClose" class="btn-Cancel" type="button" onclick="window.parent.history.back()"
                            value="Close" accesskey="C" />
                    </td>
                </tr>
            </asp:Panel>
        </table>
    </asp:Panel>
    <asp:Panel ID="pnlAccessDenied" runat="server" Visible="false">
        <table cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td style="text-align: center;">
                    <asp:Label ID="lblAccessDeniedMsg" runat="server" Text="" Font-Size="Medium" ForeColor="Red"
                        Font-Bold="True" Visible="false"></asp:Label>
                    <asp:Label ID="lblUserNotvailable" runat="server" Text="" Font-Size="Medium" ForeColor="Red"
                        Font-Bold="True" Visible="false"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: center; padding-top: 10px;">
                    <asp:Image ID="Image1" runat="server" ImageUrl="~/_layouts/1033/IMAGES/IRForm/AccessDeniedImage.png" />
                </td>
            </tr>
            <tr>
                <td style="text-align: center; padding-top: 10px">
                    <input id="butonclose" class="btn-Cancel" type="button" onclick="window.parent.history.back()"
                        value="Close" accesskey="C" />
                </td>
            </tr>
        </table>
    </asp:Panel>
    <script language="javascript" type="text/javascript">

        var element2;

        document.getElementById('<%= lblError.ClientID  %>').innerHTML = "";
        document.getElementById('<%= lblError.ClientID  %>').style.display = "none";

        element2 = document.getElementById('<%= txtPassView.ClientID %>');
        if (element2 != null) {
            element2.style.display = "none"
        }

        function getParameterByName(name) {
            name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
            var regexS = "[\\?&]" + name + "=([^&#]*)";
            var regex = new RegExp(regexS);
            var results = regex.exec(window.location.search);
            if (results == null)
                return "";
            else
                return decodeURIComponent(results[1].replace(/\+/g, " "));
        }

        function isNumberKey(evt) {
            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode > 31 && (charCode < 48 || charCode > 57))
                return false;
            return true;
        }

        var ckVal;
        function fnViewPass() {

            ckVal = document.getElementById("<%=ckPassWord.ClientID%>").checked;
            var element1 = document.getElementById('<%= txtPassWord.ClientID %>');
            var element2 = document.getElementById('<%= txtPassView.ClientID %>');

            if (element1 != null || element1 != "") {
                if (ckVal == true) {
                    element1.style.display = "none";
                    element2.style.display = "block";
                    element2.value = element1.value;
                    return true;
                }
                else {

                    element1.style.display = "block";
                    element2.style.display = "none";
                    element2.value = "";
                    return true;
                }
            }
        }

        function fnValidation() {
            debugger;
            var querystringval = getParameterByName('Mode');
            isDateEmpty = false;

            document.getElementById('<%= lblError.ClientID  %>').innerHTML = "";
            var rval = true;

            var err;

            Trim(document.getElementById('<%= txtFirstName.ClientID  %>'));
            Trim(document.getElementById('<%= txtLastName.ClientID  %>'));
            Trim(document.getElementById('<%= ddlDivision.ClientID  %>'));
            Trim(document.getElementById('<%= ddlDepartment.ClientID  %>'));
            Trim(document.getElementById('<%= txtUserNameSuggestion.ClientID  %>'));
            Trim(document.getElementById('<%= TxtComments.ClientID  %>'));

            if (querystringval != "New") {
                Trim(document.getElementById('<%= txtUserName.ClientID  %>'));
                Trim(document.getElementById('<%= txtPassWord.ClientID  %>'));
                Trim(document.getElementById('<%= txtemailAdd.ClientID  %>'));
            }

            if (querystringval == "New") {
                if (document.getElementById('<%= txtFirstName.ClientID  %>').value == "") {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = document.getElementById('<%= txtFirstName.ClientID  %>');
                    rval = false;
                }

                else if (document.getElementById('<%= txtLastName.ClientID  %>').value == "") {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = document.getElementById('<%= txtLastName.ClientID  %>');
                    rval = false;
                }

                else if (document.getElementById('<%= ddlDivision.ClientID  %>').value == "Select") {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = document.getElementById('<%= ddlDivision.ClientID  %>');
                    rval = false;
                }

                else if (document.getElementById('<%= ddlDepartment.ClientID  %>').value == "Select") {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = document.getElementById('<%= ddlDepartment.ClientID  %>');
                    rval = false;
                }

                else if (document.getElementById('<%= txtUserNameSuggestion.ClientID  %>').value == "") {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = document.getElementById('<%= txtUserNameSuggestion.ClientID  %>');
                    rval = false;
                }

                else if (document.getElementById('<%= TxtComments.ClientID  %>').value == "")
                {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = document.getElementById('<%= TxtComments.ClientID  %>');
                    rval = false;
                }

            }

            if (querystringval != "New") {

                if (document.getElementById('<%= txtUserName.ClientID  %>').value == "") {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = document.getElementById('<%= txtUserName.ClientID  %>');
                    rval = false;
                }

                else if (document.getElementById('<%= txtemailAdd.ClientID  %>').value == "") {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = document.getElementById('<%= txtemailAdd.ClientID  %>');
                    rval = false;
                }

                else if (document.getElementById('<%= txtemailAdd.ClientID  %>').value != "") {
                    var email;
                    objFocus = document.getElementById('<%= txtemailAdd.ClientID %>');
                    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                    if (!filter.test(objFocus.value)) {
                        ErrorMsg = "Please provide a valid email address";
                        rval = false;
                    }

                    else if (document.getElementById('<%= txtPassWord.ClientID  %>').value == "") {
                        ErrorMsg = "Fields marked with (*) cannot be left blank";
                        objFocus = document.getElementById('<%= txtPassWord.ClientID  %>');
                        rval = false;
                    }

                    else if (document.getElementById('<%= TxtComments.ClientID  %>').value == "") {
                        ErrorMsg = "Fields marked with (*) cannot be left blank";
                        objFocus = document.getElementById('<%= TxtComments.ClientID  %>');
                        rval = false;
                    }
                }

            }

            if (rval == false) {
                document.getElementById('<%= lblError.ClientID  %>').style.display = "block";
                document.getElementById('<%= lblError.ClientID  %>').innerHTML = ErrorMsg;
                objFocus.focus();
            }
            return rval;
        }
    
    </script>
</asp:Content>
<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
    E-Mail_ID_Request_Form
</asp:Content>
<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea"
    runat="server">
    E-Mail_ID_Request_Form
</asp:Content>
